home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
biz
/
swood
/
FWTabTools.lha
/
FWTabTools
/
FWTableFormat.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-01-04
|
11KB
|
508 lines
/* $VER: 0.14 , (04.01.1998), © by Thorsten Willert
Macro um FinalWriter Tabelleninhalte zu formatieren
-------------------------------------------------------*/
ADDRESS = 'FinaW'
OPTIONS CACHE RESULTS
STATUS PORTNAME
FW = RESULT
ADDRESS = FW
SIGNAL ON BREAK_C
SIGNAL ON HALT
SIGNAL ON SYNTAX
/*-----------------------------------------------*/
RT.Version = "Version 0.14"
RT.Title = "FWTableFormat"
RT.Para1 = "rt_pubscrname = FinalWriterPubScreen rt_topoffset = 50 rt_reqpos = reqpos_topleftwin"
RT.Copyright = "© 1997-98, by Thorsten Willert"
R = '0A'X
Format.Style = "NORMAL"
Format.Justify = "LEFT"
Format.Text2 = "\N \A M=1"
/*-----------------------------------------------*/
IF ~show('L',"rexxreqtools.library") THEN DO
IF ~addlib('rexxreqtools.library',0,-30,0) THEN DO
'ShowMessage 1 1 "Error ..." "Missing rexxreqtools.library!" "" "Exit !!" "" ""'
EXIT 20
END
END
IF EXISTS("ENVARC:FWTableFormat.prefs") THEN
DO
IF OPEN(File,"ENVARC:FWTableFormat.prefs","R") THEN Format.Text2 = READLN(File)
CLOSE( File )
END
DO FOREVER
IF Info("_Formatieren|_Reset|_Hilfe|_Ende" ) == 0 THEN LEAVE
ELSE IF GetCursor() = 1 THEN
DO
Func = RowCol()
IF Func = 1 THEN
DO
CALL GetCursor()
CALL FormatiereCR
CALL SetOldCursor
END
ELSE IF Func = 2 THEN
DO
CALL GetCursor()
CALL FormatiereC
CALL SetOldCursor
END
ELSE IF Func = 3 THEN
DO
CALL GetCursor()
CALL FormatiereR
CALL SetOldCursor
END
END
ReDraw
END
/*-----------------------------------------------*/
Ende:
IF OPEN( File ,"ENVARC:FWTableFormat.prefs","W" ) THEN
WRITELN( File , Format.Text2 )
CLOSE( File )
EXIT
/*-----------------------------------------------*/
RowCol:
RoCo = rtezrequest("Formatieren:","_Alles|_Spalte|_Zeile|_Zurück",RT.Title)
RETURN RoCo
/*-----------------------------------------------*/
GetCursor:
RESULT=""
ADDRESS(FW)
TableGetActiveCell
PARSE VAR RESULT Zeile Spalte
OldZeile = Zeile
OldSpalte = Spalte
IF Zeile = "" | Spalte = "" THEN /* Geht nicht über GetObjektType */
DO
CALL KeineTabelle
RETURN 0
END
TableGetRows
PARSE VAR RESULT Muell Zeilen
TableGetColumns
PARSE VAR RESULT Muell Spalten
RETURN 1
/*-----------------------------------------------*/
SetOldCursor:
TableSetActiveCell OldZeile OldSpalte
RETURN
/*-----------------------------------------------*/
FormatiereC:
ADDRESS (FW)
i = 1
DO FOREVER
TableSetActiveCell Zeile Spalte
CALL Format
IF Zeile=Zeilen THEN LEAVE
Zeile=Zeile+1
i = i + 1
END
Redraw
RETURN
/*-----------------------------------------------*/
FormatiereR:
ADDRESS (FW)
i = 1
DO FOREVER
TableSetActiveCell Zeile Spalte
CALL Format
IF Spalte=Spalten THEN LEAVE
Spalte=Spalte+1
i = i + 1
END
Redraw
RETURN
/*-----------------------------------------------*/
FormatiereCR:
i = 0
OldZeile= Zeile
DO FOREVER
Zeile = OldZeile
TableSetActiveCell Zeile Spalte
CALL Format
DO FOREVER
TableSetActiveCell Zeile Spalte
CALL Format
IF Zeile>=Zeilen THEN LEAVE
Zeile=Zeile+1
END
IF Spalte>=Spalten THEN LEAVE
Spalte=Spalte+1
END
RETURN
/*-----------------------------------------------*/
Format:
ADDRESS(FW)
IF Format.Copy ~= "" THEN Type Format.Copy
IF Func ~= 1 THEN
DO
IF Format.Count=1 THEN
DO
IF Format.Copy ~= "" THEN Type '20'X i
ELSE Type i '20'X
END
IF Format.CountA=1 & i <= 27 THEN
DO
IF Format.Copy ~= "" THEN TYPE Type '20'X D2C(i+64)
ELSE Type D2C(i+64) '20'X
END
ELSE Format.CountA = 0
END
SelectAll
Extract
Text = TRANSLATE( STRIP( RESULT , "T" , '0A'X ),".",",")
IF Format.Auto = "AUTO" THEN
DO
Style Format.Style
IF Format.Color ~= "" THEN FontColor Format.Color
IF Format.Font ~= "" THEN Font Format.Font
IF Format.Size ~= "" THEN FontSize Format.Size
IF DATATYPE( Text , "NUMERIC" ) THEN Format.Justify = "RIGHT"
ELSE Format.Justify = "LEFT"
CALL Margin(Format.Margin)
Style Format.Style
Justify Format.Justify
END
ELSE
DO
CALL Margin(Format.Margin)
IF Format.Clear = 1 THEN Clear
Style Format.Style
Justify Format.Justify
IF Format.Color ~= "" THEN FontColor Format.Color
IF Format.Font ~= "" THEN Font Format.Font
IF Format.Size ~= "" THEN FontSize Format.Size
END
RETURN
/*-----------------------------------------------*/
Margin: PROCEDURE EXPOSE Format. FW
PARSE ARG Rand
IF Format.Justify = "LEFT" THEN
DO
SelectAll
Extract
Text = RESULT
Text = STRIP(Text)
Text = STRIP(Text,"T",'0A'X)
Clear
Type Text
IF Rand > 0 THEN
DO
AltDown
Cursor Left
Type COPIES(" ",Rand)
END
END
IF Format.Justify = "RIGHT" THEN
DO
Rand = 0.1 * Rand
ADDRESS(FW)
RightMargin Rand
END
RETURN
/*-----------------------------------------------*/
KeineTabelle:
rtezrequest("Zuerst eine Tabelle auswählen"||R||,
"und Cursor positioniern!","_Weiter",RT.Title)
RETURN
/*-----------------------------------------------*/
Info:
PARSE ARG Taste1
IF Format.Text2 ~= "" THEN Format.Text = STRIP(Format.Text2)
DO FOREVER
res = rtgetstring(Format.Text,RT.Version||","||R||RT.Copyright,RT.Title,Taste1,RT.Para1)
IF rtresult = 2 THEN Format.Text = "\N \A M=1"
ELSE IF rtresult = 3 THEN CALL Hilfe
ELSE IF rtresult = 1 THEN LEAVE
ELSE RETURN rtresult
END
CALL SelectFormat(res)
RETURN rtresult
/*------------------------------------------------*/
SelectFormat: PROCEDURE EXPOSE Format.
PARSE ARG A
res = UPPER(A)
Format.Text2 = ""
SELECT
WHEN FIND( res, "\N" ) >= 1 THEN
DO
Format.Style = "NORMAL"
Format.Text2 = Format.Text2 "\N"
END
WHEN FIND( res, "\U" ) >= 1 THEN
DO
Format.Style = "UNDERLINE"
Format.Text2 = Format.Text2 "\U"
END
WHEN FIND( res, "\DU" ) >= 1 THEN
DO
Format.Style = "DUNDERLINE"
Format.Text2 = Format.Text2 "\DU"
END
WHEN FIND( res, "\S" ) >= 1 THEN
DO
Format.Style = "STRIKETHRU"
Format.Text2 = Format.Text2 "\S"
END
WHEN FIND( res, "\B" ) >= 1 THEN
DO
Format.Style = "BOLD"
Format.Text2 = Format.Text2 "\B"
END
WHEN FIND( res, "\I" ) >= 1 THEN
DO
Format.Style = "ITALIC"
Format.Text2 = Format.Text2 "\I"
END
OTHERWISE Format.Style = ""
END
SELECT
WHEN FIND( res, "\L" ) >= 1 THEN
DO
Format.Justify = "LEFT"
Format.Text2 = Format.Text2 "\L"
Format.Auto = ""
END
WHEN FIND( res, "\C" ) >= 1 THEN
DO
Format.Justify = "CENTER"
Format.Text2 = Format.Text2 "\C"
Format.Auto = ""
END
WHEN FIND( res, "\R" ) >= 1 THEN
DO
Format.Justify = "RIGHT"
Format.Text2 = Format.Text2 "\R"
Format.Auto = ""
END
WHEN FIND( res , "\A" ) >= 1 THEN
DO
Format.Auto = "AUTO"
Format.Text2 = Format.Text2 "\A"
END
OTHERWISE
DO
Format.Justify = ""
Format.Auto = ""
END
END
res = TRANSLATE(res, " ", "=" )
SizePos = FIND( res, "SIZE" )
FontPos = FIND( res, "FONT")
MPos = FIND( res, "M")
CountPos = FIND( res, "COUNT")
CountAPos= FIND( res, "COUNTA")
ClZ = FIND( res, "CLEAR")
CopyPos = FIND( res, "COPY")
ColorPos = FIND( res, "COLOR")
IF SizePos >= 1 THEN
DO
Format.Size = SUBWORD( res,SizePos+1,1)
IF Format.Size <= 4 | DATATYPE( Format.Size,"WHOLE") = 0 THEN Format.Size = 4
Format.Text2 = Format.Text2 "SIZE="||Format.Size
END
ELSE Format.Size = ""
IF FontPos >= 1 THEN
DO
Format.Font = SUBWORD( res,FontPos+1,1)
IF Format.Font ~= "" THEN Format.Font = Format.Font
Format.Text2 = Format.Text2 "FONT="||Format.Font
END
ELSE Format.Font = ""
IF ColorPos >= 1 THEN
DO
Format.Color = SUBWORD( res,ColorPos+1,1)
IF Format.Color ~= "" THEN Format.Color = Format.Color
Format.Text2 = Format.Text2 'COLOR='||Format.Color
END
ELSE Format.Color = ""
IF MPos >= 1 THEN
DO
Format.Margin = SUBWORD( res, MPos+1,1)
IF DATATYPE( Format.Margin , "WHOLE") = 0 THEN Format.Margin = 0
Format.Text2 = Format.Text2 "M="||Format.Margin
END
ELSE Format.Margin = 0
IF CountPos >= 1 THEN
DO
Format.Count = 1
Format.Text2 = Format.Text2 "COUNT"
END
ELSE Format.Count = 0
IF CountAPos >= 1 THEN
DO
Format.CountA = 1
Format.Text2 = Format.Text2 "COUNTA"
END
ELSE Format.CountA = 0
IF ClZ >= 1 THEN
DO
Format.Clear = 1
Format.Text2 = Format.Text2 "CLEAR"
END
ELSE Format.Clear = 0
IF CopyPos >= 1 THEN
DO
Text = TRANSLATE(A, " ", "=" )
Format.Copy = SUBWORD( Text,CopyPos+1)
PARSE ARG Format.Copy '"'Format.Copy'"'
Format.Text2 = Format.Text2 'COPY="'||Format.Copy||'"'
END
ELSE Format.Copy = ""
RETURN res
/*-----------------------------------------------*/
Hilfe:
rtezrequest("Formatiert Zellen ab Cursorposition:"||R||R||,
"\N = Normal"||R||,
"\U = Unterstrichen"||R||,
"\DU = Doppelt unterstrichen"||R||,
"\S = Durchgestrichen"||R||,
"\B = Bold"||R||,
"\I = Italic"||R||,
"\L = Links justiert"||R||,
"\C = Zentriert"||R||,
"\R = Rechts justiert"||R||,
"\A = Auto-Justierung (Text links, Zahlen Rechts)"||R||,
"M=X = Rand (nur mit Justierung wirksam)"||R||,
"SIZE=X = Schriftgröße"||R||,
"FONT=X = Schriftname"||R||,
"COLOR=X = Schriftfarbe"||R||,
"COUNT = Nummerierung"||R||,
"COUNTA = Alphabetische Nummerierung"||R||,
"CLEAR = Inhalt löschen"||R||,
"COPY=X = Mit X ausfüllen (! letztes Argument)","_Aha",RT.Title)
RETURN
/*-----------------------------------------------*/
HALT:
BREAK_C:
rtezrequest("Macro wurde abgebrochen ... ","_Weiter",RT.Title)
EXIT 10
/*-----------------------------------------------*/
SYNTAX:
rtezrequest("Fehler!","_Weiter|_Hilfe",RT.Title)
IF rtresult == 0 THEN CALL Hilfe
EXIT 10